package StudyCode.summary.mycollection;

import java.util.Map;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class MapDeepEquals {
	public static <K, V> boolean deepEquals(final Map<K, V> m1,
	                                        final Map<? extends K, ? extends V> m2) {
		for (Map.Entry<K, V> entry1 : m1.entrySet()) {
			if (!m2.containsKey(entry1.getKey()))
				return false;
			else {
				if (!m2.get(entry1.getKey()).equals(entry1.getValue()))
					return false;
			}
		}
		for (K k2 : m2.keySet()) {
			if (!m1.containsKey(k2))
				return false;
		}
		return true;
	}
}
